<?php

require_once "LoginHandler.php";

	class LoginView {
		
		//Private variables for use in getting the login information
		private $m_getUserName = "Username";
		private $m_getPassword = "Password";
		private $m_triedToLogin = "Login";
		private $m_triedToLogOut = "Logout";
		
		//Skriver ut inloggningsformuläret
		public function DoLoginBox() {
			
		return "
		<form method='get'>
			<fieldset>
				<legend>Login</legend>
					<p><label for='name'>Name: </label><input type='text' id='name' name='$this->m_getUserName'/></p>
					<p><label for='password'>Password: </label><input type='text' id='password' name='$this->m_getPassword'/></p>
					<p><input type='submit' value='Login' name='$this->m_triedToLogin'/>
					<label for='rememberMe'>Remember me:</label><input type='checkbox' id='rememberMe' name='RememberMe' /></p>
			</fieldset>
		</form>";
		}
		
		//Skriver ut logout-knappen
		public function DoLogoutBox(){
			
			return "
			<form>
				<input type='submit' value='Logout' name='$this->m_triedToLogOut' />
			</form>";
		}
		
		//Tar hand om lösenordet
		public function GetUserName() {
			
	    	if (isset( $_GET[$this->m_getUserName]) == true) {
	      		return $_GET[$this->m_getUserName];
			} 
	    	return NULL;
  		}
		
		//Tar hand om lösenordet
		public function GetPassword() {
			
	    	if (isset( $_GET[$this->m_getPassword]) == true) {
	      		return $_GET[$this->m_getPassword];
			} 
	    	return NULL;
  		}
  		
  		//Ser om login-knappen trycks ner
  		public function TriedToLogin() {
			
	    	if (isset( $_GET[$this->m_triedToLogin]) == true) {
				return $_GET[$this->m_triedToLogin];
			}
	    	return FALSE;
  		}
  		
  		//Ser om logout-knappen trycks ner
  		public function TriedToLogOut() {
			
	    	if (isset( $_GET[$this->m_triedToLogOut]) == true) {
	      		return $_GET[$this->m_triedToLogOut];
			} 
	    	return FALSE;
  		}
	}
?>